#include <stdio.h>
#include <assert.h>
#include <stdlib.h>


#include "../evaluater.h"
#include "../lexical.h"
#include "../storage.h"

void test_obarray()
{
    list_prepare();
    char* p = "hello!";
    char* q = "worlD";
    Indx p_idx, q_idx;
    List* l;
    size_t i = 0;
 
    p_idx = obarray_append( p, strlen(p) );
    q_idx = obarray_append( q, strlen(q) );
    l = obarray_get( p_idx );
    assert( l->Cdr == 6 );
    for( i = 0; i < l->Cdr; i++ )
        putchar( *((char*)l->Car + i ));
    putchar('\n');
    
    l = obarray_get( q_idx);
    for( i = 0; i < l->Cdr; i++)
        putchar( *((char*)l->Car + i));
    putchar('\n');
    list_close();
}

void test_type()
{
    Indx a = 0x0F221232;
#define TEST_TYPE( x, t) \
    SET_TYPE ( (x), t ); \
    assert( TYPE(x) == t )
    abort();
    TEST_TYPE( a, EList );
    printf("a is 0x%X\n", a );
    TEST_TYPE( a, ESymbol);
    TEST_TYPE( a, EInteger);
    TEST_TYPE( a, EString);
#undef TEST_TYPE    
    printf( "Type Test passed!\n");
    
}

int main()
{
    test_type();
    test_obarray();
    return 0;
}  
